package org.foreningsgatan.genetics.racers;

import org.foreningsgatan.genetics.Generation;
import org.foreningsgatan.genetics.Program;

public class GeneticRacers {
	private Generation<Sources, Actions> currentGeneration;
	
	private void createFirstGeneration() throws Exception {
		RacingSimulation racingSimulation = new RacingSimulation();

		currentGeneration = new Generation<Sources, Actions>(
				Configuration.sPopulation, racingSimulation, 
				Sources.values(), Actions.values());
		currentGeneration.generateAndSimulateRandomPopulation(8);
	}
	
	public GeneticRacers() throws Exception  {
		createFirstGeneration();
		
		Program<Sources, Actions> fittest = currentGeneration.getFittest();
		System.out.println(fittest.getResultSet());
		
		fittest.getRootNode().log(0);
	}

	public static void main(String[] args) throws Exception {
		new GeneticRacers();
	}
}
